package main

import (
	"context"
	"flag"
	"git.xiaotuo.co/micro/oss/config"
	"git.xiaotuo.co/micro/oss/logic"
	log "github.com/sirupsen/logrus"
	"os/signal"
	"syscall"
)

var (
	logPath    string
	configPath string
)

func main() {
	flag.StringVar(&logPath, "logPath", "./logs", "日志目录")
	flag.StringVar(&configPath, "config", "./etc/client.json", "配置文件地址")
	flag.Parse()

	conf := &config.Config{}
	if err := config.Load(configPath, conf); err != nil {
		log.Fatal("config load: %v", err)
	}

	logic.InitLogger(logPath)
	logic.Init(logic.WithConfig(conf))

	ctx, _ := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGKILL, syscall.SIGTERM)
	logic.Resources.CheckLogic.Run(ctx)
	<-ctx.Done()
	log.Info("exit")
}
